<extend name="Public:innerbase"/>
<script src="/Public/Common/vote/js/script.js" type="text/javascript"></script>
<block name="content">
	<div class="container-fluid">
		<div style="margin:10px 0;">
			<a href="{:U('Votey/index')}" class="btn btn-default btn-sm">返回</a>
		</div>		
		<a style="margin-bottom:10px;" href="{:U('Votey/add_item',['vote_id'=>$_GET['vote_id']])}" class="btn btn-success">添加选项</a>
		
		&nbsp;&nbsp;&nbsp;&nbsp;<if condition="$votex['reg_sign'] eq 1"><button  id="delall" type="button" class="btn btn-sm btn-danger dropdown-toggle" data-toggle="dropdown" style="    background-color: #B42FA3;margin-bottom: 10px;height: 32px;
}">批量审核 
						</button></if>

						<script type="text/javascript"> 
						var jsonCity = "/Public/Common/vote/js/content/json-array-of-city.js"; 
						var jsonDistrict = "/Public/Common/vote/js/content/json-array-of-district.js"; 
							function getcity(num,id){
								$.get( jsonCity, 
									function (r) { 
										var pre=num; // pre: 初始值 
										for (var i = 0; i < r.length; i++) { 
											s = ''; 
											if (pre !== "" && pre !== 0 && r[i].code == pre) { 
												//alert($("#"+id).html());
												//document.write(r[i].name);
												 $("#"+id).append(r[i].name);

											} 
										} 		
									}, "json" ); 
							}
							function getDistrict(num,id){
								$.get( jsonDistrict, 
									function (r) { 
										var pre=num; // pre: 初始值 
										for (var i = 0; i < r.length; i++) { 
											s = ''; 
											if (pre !== "" && pre !== 0 && r[i].code == pre) { 
				
												 $("#"+id).append(r[i].name);

											} 
										} 		
									}, "json" ); 
							}
						
						
		

	
	</script>
		<table class="table table-striped wm-table-bordered">
			<thead>
				<tr>
				<if condition="$votex['reg_sign'] eq 1">
					<th width="50" class="select"><input type="checkbox" value="反选" name="button" id="selected"  style="color:#94D38A;"></th>
				</if>	
					<th>编号</th>
					<th>序号</th>
					<th class="time">名称</th>
					<th class="time">图片</th>
					<th>介绍</th>
					
					<th>票数</th>
					<th>来源</th>
					<if condition="$votex['reg_sign'] eq 1">	
					<th>审核状态</th>	
					</if>
					<th class="norightborder">操作</th>		
					<if condition="$votex['ontelphone'] eq 1">	
					<th>手机号</th>	
					</if>
					<if condition="$votex['msg1'] neq ''">
						<th>{$votex['msg1']}</th>
						<th>城市</th>
					</if>
				</tr>
			</thead>
			<tbody>
				<volist id="list" name="list">
				<tr>
				<if condition="$votex['reg_sign'] eq 1">
					<td><input type="checkbox" name="items" value="{$list.id}"  class="checkitem" /></td>
				</if>	
					<td>{$list.serial_id}</td>
					<td>{$list.rank}</td>
					<td>{$list.title}</td>
					<td><img src="{$list.img}" style="width:100px;" /></td>
					<td>{$list.intro}</td>
					<td>{$list.vote_num}</td>
					<td><if condition="$list['wechat_id'] neq ''">微信报名({$list.wechat_name})<else/>线下报名</if></td>
					
					<if condition="$votex['reg_sign'] eq 1">	
					<td><if condition="$list['istop'] eq 1">
			<a class="btn btn-xs btn-info"  style="background-color:#B42FA3" href="{:U('User/Votey/changetop',array('chk_value'=>$list['id'],'token'=>$token,'cid'=>$_GET['vote_id'],'istop'=>2))}">
				已审核
			</a>
			<else />
			<a class="btn btn-xs btn-info" href="{:U('User/Votey/changetop',array('chk_value'=>$list['id'],'token'=>$token,'cid'=>$_GET['vote_id'],'istop'=>1))}">
				未审核
			</a>
				
			</if>
		</td>

					</if>
					
					<td class="norightborder">
						<a href="javascript:spark.confirm_jump('您确定要删除吗?', '{:U('Votey/item_del',array('id'=>$list['id'],'vid'=>$_GET['vote_id']))}');">删除</a> | 
						<a href="{:U('Votey/item_edit',array('id'=>$list['id'],'vid'=>$_GET['vote_id']))}">编辑</a> 
					</td>
					<if condition="$votex['ontelphone'] eq 1">	
						<td>{$list.telphone}</td>
					</if>

					<if condition="$votex['msg1'] neq ''">
						<td>{$list.msg1}</td>
						

				<td id="{$list.id}">
						<if condition="$list['city'] neq ''">	
				<script type="text/javascript">
                 getcity({$list.city},{$list.id});
                 getDistrict({$list.district},{$list.id});
             	</script>
             	 </if> 

				 <td>

						
					</if>
				</tr>
				</volist>
			</tbody>
        </table>
		<div>{$page}</div>
	</div>
	<script type="text/javascript"> 
	var jsonCity = "/Public/Common/vote/js/content/json-array-of-city.js"; 
	var jsonDistrict = "/Public/Common/vote/js/content/json-array-of-district.js"; 
	function getcity(num){
		for (var i = 0; i < jsonCity.length; i++) { 
		if (pre !== "" && pre !== 0 && jsonCity[i].code === pre) { 
			return jsonCity[i].name; 
		} 

	}
	
$(function(){
	$("#delall").click(function(){
		var arrChk=$("input[name='items']:checked");
		var allid='';
		 $(arrChk).each(function(){
			allid = allid + this.value +',';     
		 });
		 if(allid !=''){
			 $.ajax({
					type	:	"get",
					url  	:	"{:U('Votey/verifyAll',array('cid'=>$cid))}",
					data	:	"allid=" + allid,
					timeout :	30000,
					dataType	:	"json",
					success:function(dataHtml){
						alert('批量审核成功');
						location.reload();
					},
					error:function(XMLHttpRequest, textStatus, errorThrown){
						alert('操作失效')
					}
				});	 
		 }				
	})
	
	$("#selected").click(function(){
		$('input[name="items"]').attr("checked",this.checked); 	 
	})
})
</script>
</block>
